F5: debug
Ctrl F5: run
Shift F5: stop debug
Ctrl Shift B: build solution
MVC convention vs configuration
Controller default route:
/home (/home/index)
return View(); -> get view with same name as method in folder of controller name
(convention: xxxController : Controller)
folder: View/Home/Index.cshtml
return View("About");
folder: View/Home/About.cshmtl
View searching:
View/Home
View/Shared
===
select code
alt + arrow to move code up/down
App_Start/RouteConfig.cs
select first match -> order matters
return Content("some string");
===
ActionResult class
and built-in action result types (view, partial view, content, json, javascript, etc.)
return JSON: JsonBehavior.AllowGet
===
Action selector attribute:
[HttpGet]
[HttpPost]
ViewBag to pass session data to View from Controller
MVC 5: Attribute Routing vs RouteConfig
===
Authorization filter:
[Authorize]: authenticated users
[Authorize(Roles="Admin")]
Custom Action Filter
xxxAtrribute : ActionFilterAttribute
override OnActionExecuting/OnActionExecuted(ActionExecutedContext con)
do task
base.OnActionExecuted(con);
[xxx]
some Action();
Global filter:
App_Start/FilterConfig.cs
Web.config